<!--
 * @Author: wwssaabb
 * @Date: 2021-08-16 17:58:04
 * @LastEditTime: 2021-08-17 09:02:14
 * @FilePath: \axios_demo\base\template.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
  <title>Document</title>
</head>

<body>
  <div class="container">
    <h2 class="page-header">基本使用</h2>
    <button class="btn btn-primary">发送GET请求</button>
    <button class="btn btn-warning">发送POST请求</button>
  </div>

  <script>
    let buts=document.querySelectorAll('button')

    //axios.create 能创建不同的请求对象，这些对象的功能和axios对象几乎一样
    let ajax=axios.create({
      baseURL:'https://v2.alapi.cn/api/',
      timeout:3000
    })

    ajax({
      url:'joke?token=GjEwhgBuYxJeNoqJ'
    }).then(res=>console.log(res))
    


  </script>
</body>

</html>